package com.bjpowernode.springboot.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

@Controller
public class MyController {

    @RequestMapping(value="/user/detail")
    public @ResponseBody Object userDetail(){
        Map<String,Object> retMap=new HashMap<>();
        retMap.put("id",1001);
        retMap.put("username","王五");

        return retMap;
    }

    @RequestMapping(value="/user/page/detail",produces = "text/plain;charset=utf-8")
    public String userPageDetail(Model model){
        model.addAttribute("id",1001);
        model.addAttribute("username","李四");

        return "userDetail";
    }
}
